<?php use_helper('Object', 'Validation', 'ObjectAdmin', 'I18N', 'Date') ?>

<?php use_stylesheet('/sf/sf_admin/css/main') ?>

<div id="sf_admin_container">

    <h1><?php echo __('settings') ?></h1>

    <div id="sf_admin_content">

        <?php echo form_tag(
                    'tree/saveSettings', array(
                    'id'        => 'sf_admin_edit_form',
                    'name'      => 'sf_admin_edit_form',
                    'multipart' => true,
        )) ?>

        <?php echo input_hidden_tag('id', $obj->getId()) ?>

<?php if( $obj->getObjId() < 1 ): ?>

    <?php foreach( MyConstants::getModuleTypeList() as $key => $value ): ?>

        <?php if( $key != MyConstants::MODULE_VIRTUAL ): ?>
            <?php echo link_to(
                            image_tag('module_add_' . $value . '.png')
                            , 'tree/change?id=' . $obj->getId() . '&module_type=' . $key
                            , array(
                                'confirm' => __('Are you sure?!')
                                , 'border' => 0
                                , 'alt' => __('Add ' . $value . ' module')
                                , 'title' => __('Add ' . $value . ' module')
                            )
                        ) ?>
        <?php endif; ?>
    <?php endforeach; ?>


<?php else: ?>

    <?php echo link_to(
                    image_tag('folder_error.png')
                    , 'tree/resetmodule?id=' . $obj->getId()
                    , array(
                        'confirm' => __('Are you sure?!')
                        , 'border' => '0'
                        , 'alt' => __('Reset to folder')
                        , 'title' => __('Reset to folder')
                    )
                ) ?>
    <?php foreach( MyConstants::getModuleTypeList() as $key => $value ): ?>

        <?php if( $key == MyConstants::MODULE_VIRTUAL ): ?>

        <?php elseif( $key == $obj->getObjType() ): ?>
            <b><?php echo $value; ?></b>
        <?php else: ?>
            <?php echo link_to(
                            image_tag('module_add_' . $value . '.png')
                            , 'tree/change?id=' . $obj->getId() . '&module_type=' . $key
                            , array(
                                'confirm' => __('Are you sure?!')
                                , 'border' => 0
                                , 'alt' => __('Change to ' . $value . ' module')
                                , 'title' => __('Change to ' . $value . ' module')
                            )
                        ) ?>
        <?php endif; ?>

    <?php endforeach; ?>


<?php endif; ?>


    <?php include_component(
            'textmodule'
            , 'gallery_list'
            , array(
                'text_module' => TextModule::getById($obj->getObjId())
            )
    ) ?>

        <ul class="sf_admin_actions">
          <li><?php echo button_to(
                            __('list')
                            , 'tree/list'
                            , array (
                                'class' => 'sf_admin_action_list',
                            )
                        ) ?></li>
          <li><?php echo button_to(
                            __('edit')
                            , 'tree/edit?id=' . $obj->getId()
                            , array (
                                'class' => 'sf_admin_action_cog',
                            )
                        ) ?></li>
          <li><?php echo submit_tag(__('save'), array (
          'name' => 'save',
          'class' => 'sf_admin_action_save',
        )) ?></li>
          <li><?php echo submit_tag(__('save and add'), array (
          'name' => 'save_and_add',
          'class' => 'sf_admin_action_save_and_add',
        )) ?></li>
        </ul>


        </form>

    </div>

    <div id="sf_admin_footer">


    </div>

</div>
